using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Resources;
using System.Net;
using System.Net.Sockets;
using Microsoft.Win32;
using System.Threading;
using System.Diagnostics;
using System.Runtime.InteropServices;


namespace NeverFeel
{
	public class BaseForm : System.Windows.Forms.Form
	{
		protected System.Windows.Forms.PictureBox ClosePictureBtn;
		
		private const int WM_NCHITTEST = 0x84;
		private const int HTCLIENT = 0x1;
		private const int HTCAPTION = 0x2;
		protected CustomPanel HeaderPanel;
		protected CustomPanel TransparentPanel;
		
		public BaseForm()
		{		
			InitializeComponent();
		}
		

		#region Windows Form Designer generated code
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			base.Dispose( disposing );
		}
		

		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BaseForm));
			this.TransparentPanel = new CustomPanel();
			this.HeaderPanel = new CustomPanel();
			this.ClosePictureBtn = new System.Windows.Forms.PictureBox();
			this.TransparentPanel.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.ClosePictureBtn)).BeginInit();
			this.SuspendLayout();
			// 
			// TransparentPanel
			// 
			this.TransparentPanel.BackColor = System.Drawing.Color.LightSlateGray;
			this.TransparentPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.TransparentPanel.Controls.Add(this.HeaderPanel);
			this.TransparentPanel.Controls.Add(this.ClosePictureBtn);
			this.TransparentPanel.Dock = System.Windows.Forms.DockStyle.Fill;
			this.TransparentPanel.Location = new System.Drawing.Point(0, 0);
			this.TransparentPanel.Name = "TransparentPanel";
			this.TransparentPanel.Size = new System.Drawing.Size(262, 246);
			this.TransparentPanel.TabIndex = 15;
			// 
			// HeaderPanel
			// 
			this.HeaderPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
						| System.Windows.Forms.AnchorStyles.Right)));
			this.HeaderPanel.BackColor = System.Drawing.Color.Black;
			this.HeaderPanel.Location = new System.Drawing.Point(-1, -1);
			this.HeaderPanel.Name = "HeaderPanel";
			this.HeaderPanel.Size = new System.Drawing.Size(247, 16);
			this.HeaderPanel.TabIndex = 16;
			// 
			// ClosePictureBtn
			// 
			this.ClosePictureBtn.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.ClosePictureBtn.Image = ((System.Drawing.Image)(resources.GetObject("ClosePictureBtn.Image")));
			this.ClosePictureBtn.Location = new System.Drawing.Point(245, -1);
			this.ClosePictureBtn.Name = "ClosePictureBtn";
			this.ClosePictureBtn.Size = new System.Drawing.Size(16, 16);
			this.ClosePictureBtn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
			this.ClosePictureBtn.TabIndex = 10;
			this.ClosePictureBtn.TabStop = false;
			this.ClosePictureBtn.Click += new System.EventHandler(this.ClosePictureBtn_Click);
			// 
			// BaseForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.BackColor = System.Drawing.Color.SlateGray;
			this.ClientSize = new System.Drawing.Size(262, 246);
			this.Controls.Add(this.TransparentPanel);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.KeyPreview = true;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "BaseForm";
			this.Opacity = 0.85;
			this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
			this.Text = "Radio Status";
			this.TopMost = true;
			this.TransparentPanel.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.ClosePictureBtn)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

	
		protected void ShowForm()
		{
			//this.ShowInTaskbar = true;
			//this.WindowState = FormWindowState.Normal;
			this.Show();
			this.WindowState = FormWindowState.Normal;
		}


		protected void HideForm()
		{
			//this.ShowInTaskbar = false;
			this.WindowState = FormWindowState.Minimized;
			this.Hide();	
		}


		#region protected override void WndProc(ref Message m)
		/// <summary>
		/// WndProc
		/// </summary>
		/// <param name="m"></param>
		protected override void WndProc(ref Message m)
		{
			switch(m.Msg)
			{
				case WM_NCHITTEST:
					base.WndProc(ref m);
					if ((int)m.Result == HTCLIENT)
					{
						m.Result = (IntPtr)HTCAPTION;
					}
					return;
			}
			base.WndProc(ref m);
		}
		#endregion

		private void ClosePictureBtn_Click(object sender, EventArgs e)
		{
			HideForm();
		}

	}

}